home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1995 June / PC Answers CD-ROM - CD-ROM 8 (Future Publishing) (June 1995).BIN / vbasic / scribble.txt < prev   
Encoding:
Text File  |  1995-03-06  |  5.3 KB  |  226 lines

  1. Option Explicit
  2. '
  3. Const ScribbleMode = 0          ' Scribbling mode
  4. Const LineMode = 1              ' Drawing straight lines
  5. Const StarBurstMode = 2         ' Draw a starburst
  6. '
  7. Dim MouseDown As Integer        ' Declare mouse-down flag
  8. Dim Mode As Integer             ' Declare draw mode variable
  9. Dim StartX As Integer           ' Initial X position
  10. Dim StartY As Integer           ' Initial Y position
  11. Dim LastLineX As Integer        ' Last line end pos
  12. Dim LastLineY As Integer        ' Last line end pos
  13.  
  14. Sub Black_Click ()
  15.     ForeColor = QBColor(0)
  16. End Sub
  17.  
  18. Sub Blue_Click ()
  19.     ForeColor = QBColor(1)
  20. End Sub
  21.  
  22. Sub BWhite_Click ()
  23.     ForeColor = QBColor(15)
  24. End Sub
  25.  
  26. Sub Cyan_Click ()
  27.     ForeColor = QBColor(3)
  28. End Sub
  29.  
  30. Sub Form_Load ()
  31.     
  32.     Mode = ScribbleMode         ' Start off with scribbling
  33.     Scribble.Checked = True     ' check the Scribble item
  34.     MouseDown = False           ' And assume mouse is up
  35. End Sub
  36.  
  37. Sub Form_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  38.     
  39.     ' If the left mouse button was clicked, then set
  40.     ' up the program variables for a drawing operation
  41.  
  42.     If (Button And 1) <> 0 Then
  43.         MouseDown = True        ' Flag mouse down
  44.  
  45.         StartX = X              ' Save initial mouse down X
  46.         StartY = Y              ' Save initial mouse down Y
  47.  
  48.         LastLineX = -1          ' Init last line end pos
  49.         LastLineY = -1          ' For line drawing mode
  50.     End If
  51.  
  52.     ' If right mouse button was clicked, then just call 'Refresh'
  53.     ' This has the effect of clearing the program window
  54.  
  55.     If (Button And 2) <> 0 Then
  56.         Refresh
  57.     End If
  58. End Sub
  59.  
  60. Sub Form_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)
  61.     
  62.     'Set default drawing mode
  63.  
  64.     DrawMode = 13
  65.     If Mode = ScribbleMode Then
  66.         If MouseDown Then
  67.             CurrentX = StartX       ' Set up start point for this line
  68.             CurrentY = StartY       ' From StartX, StartY coordinates
  69.             Line -(X, Y)            ' Draw the line
  70.             StartX = X              ' Update StartX and...
  71.             StartY = Y              ' ...StartY for next time round
  72.         End If
  73.     End If
  74.  
  75.     If Mode = LineMode Then
  76.         If MouseDown Then
  77.             DrawMode = 10
  78.             If LastLineX <> -1 Then
  79.                 ' We've got an old line - need to remove it
  80.                 CurrentX = StartX
  81.                 CurrentY = StartY
  82.                 Line -(LastLineX, LastLineY)
  83.             End If
  84.  
  85.             ' Old line is gone, now draw new line
  86.             LastLineX = X
  87.             LastLineY = Y
  88.             CurrentX = StartX
  89.             CurrentY = StartY
  90.             Line -(X, Y)
  91.         End If
  92.     End If
  93.  
  94.     If Mode = StarBurstMode Then
  95.         If MouseDown Then
  96.             CurrentX = StartX
  97.             CurrentY = StartY
  98.             Line -(X, Y)
  99.         End If
  100.     End If
  101. End Sub
  102.  
  103. Sub Form_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
  104.     MouseDown = False       ' Mouse no longer down
  105.     If Mode = LineMode Then
  106.             DrawMode = 13
  107.             CurrentX = StartX
  108.             CurrentY = StartY
  109.             Line -(LastLineX, LastLineY)
  110.     End If
  111. End Sub
  112.  
  113. Sub Gray_Click ()
  114.     ForeColor = QBColor(8)
  115. End Sub
  116.  
  117. Sub Green_Click ()
  118.     ForeColor = QBColor(2)
  119. End Sub
  120.  
  121. Sub LBlue_Click ()
  122.     ForeColor = QBColor(9)
  123. End Sub
  124.  
  125. Sub LCyan_Click ()
  126.     ForeColor = QBColor(11)
  127. End Sub
  128.  
  129. Sub LGreen_Click ()
  130.     ForeColor = QBColor(10)
  131. End Sub
  132.  
  133. Sub Line_Click ()
  134.     Mode = LineMode         ' User has selected line mode
  135. End Sub
  136.  
  137. Sub LMagenta_Click ()
  138.     ForeColor = QBColor(13)
  139. End Sub
  140.  
  141. Sub LRed_Click ()
  142.     ForeColor = QBColor(12)
  143. End Sub
  144.  
  145. Sub LYellow_Click ()
  146.     ForeColor = QBColor(14)
  147. End Sub
  148.  
  149. Sub Magenta_Click ()
  150.     ForeColor = QBColor(5)
  151. End Sub
  152.  
  153. Sub P1_Click ()
  154.     DrawWidth = 1
  155. End Sub
  156.  
  157. Sub P10_Click ()
  158.     DrawWidth = 10
  159. End Sub
  160.  
  161. Sub P2_Click ()
  162.     DrawWidth = 2
  163. End Sub
  164.  
  165. Sub P3_Click ()
  166.     DrawWidth = 3
  167. End Sub
  168.  
  169. Sub P4_Click ()
  170.     DrawWidth = 4
  171. End Sub
  172.  
  173. Sub P5_Click ()
  174.     DrawWidth = 5
  175. End Sub
  176.  
  177. Sub P6_Click ()
  178.     DrawWidth = 6
  179. End Sub
  180.  
  181. Sub P7_Click ()
  182.     DrawWidth = 7
  183. End Sub
  184.  
  185. Sub P8_Click ()
  186.     DrawWidth = 8
  187. End Sub
  188.  
  189. Sub P9_Click ()
  190.     DrawWidth = 9
  191. End Sub
  192.  
  193. Sub Red_Click ()
  194.     ForeColor = QBColor(4)
  195. End Sub
  196.  
  197. Sub Scribble_Click ()
  198.     Mode = ScribbleMode       ' User has selected scribble mode
  199.     Scribble.Checked = True   ' Scribble menu item is checked
  200.     SLine.Checked = False     ' Line menu item isn't !
  201.     Starburst.Checked = False ' Startburst not checked either
  202. End Sub
  203.  
  204. Sub SLine_Click ()
  205.     Mode = LineMode           ' We're drawing straight lines
  206.     SLine.Checked = True      ' Line menu item is checked
  207.     Scribble.Checked = False  ' Scribble menu item isn't !
  208.     Starburst.Checked = False ' Starburst not checked either
  209. End Sub
  210.  
  211. Sub Starburst_Click ()
  212.     Mode = StarBurstMode      ' We're drawing starbursts
  213.     Starburst.Checked = True  ' Starburst menu item checked
  214.     Scribble.Checked = False  ' Scribble menu item isn't !
  215.     SLine.Checked = False     ' Neither is line menu
  216. End Sub
  217.  
  218. Sub White_Click ()
  219.     ForeColor = QBColor(7)
  220. End Sub
  221.  
  222. Sub Yellow_Click ()
  223.     ForeColor = QBColor(6)
  224. End Sub
  225.  
  226.